--require('shaders')
--require('world')


--[[

	Player Functionality
	
--]]
--Player initialization
function playerInit()
	x = 400
	y = 300
	maxRadius = 30
	minRadius = 20
	radius = 25
	color = {1,1,1,1}
	health = 1000
	breathDirection = "in"
end


--[[

	LOVE Code
	
--]]
--LOVE initialization for player graphics
function love.load()
	playerInit()
	
	playerPixelEffect = (shaders:getBallEffect())
	
	playerPixelEffect:send('position', x, y)
	playerPixelEffect:send('size', radius)
	playerPixelEffect:send('col', color)
end

--LOVE draw command for player
function love.draw()
	love.graphics.setPixelEffect(playerPixelEffect)
end

--LOVE update command for player
function love.update(dt)
	t = t + dt
	
	--Calculate radius
	if breathDirection == "in" then
		if radius < minRadius then
			breathDirection = "out"
		end
		radius = radius - (1/health)
	end
	if breathDirection == "out" then
		if radius > maxRadius then
			breathDirection = "in"
		end
		radius = radius + (1/health)
	end
	
	playerPixelEffect:send('position', x, y)
	playerPixelEffect:send('size', radius)
	playerPixelEffect:send('col', color)
end


--[[

	Gets and Sets

--]]
--Returns Player's X value
function getX()
	return x
end

--Returns Player's Y value
function getY()
	return y
end

--Returns Player's current health
function getHealth()
	return health
end

--Sets Player's X value to given argument
function setX(newX)
	--Bounds check
	if (newX > maxRadius) and (newY < (world:getMaxX() - maxRadius)) then
		x = newX
		return true
	else
		return false
	end
end

--Sets Player's Y value to given argument
function setY(newY)
	--Bounds check
	if (newY > maxRadius) and (newY < (world:getMaxY() - maxRadius)) then
		y = newY
		return true
	else
		return false
	end
end

--Sets Player's current health
function setHealth(hp)
	if hp < 1 then
		--invoke loss condition
		return false
	else
		health = hp
		return true
	end
end